<template>
  <div class="bg-cont">
  <div class="department-container">
    <!-- 上部内容 -->
    <div class="top-section">
      <!-- 左侧橙色区域 -->
      <div class="left-section">
        <div class="department-title">政策部门</div>
        <button class="all-department-btn">全部部门</button>
        <div class="divider-line"></div>
        <div class="feature-list">
          <div class="feature-item">——高效归类部门政策</div>
          <div class="feature-item">——实时追踪政策动向</div>
          <div class="feature-item">——最新、完善的数据内容</div>
        </div>
      </div>

      <!-- 右侧白色区域 -->
      <div class="right-section">
        <div class="section-header">
          <img :src="currentTab.icon" alt="图标" class="section-icon">
          <span class="more-text">——更多</span>
        </div>
        <div class="government-name">{{ currentTab.name }}</div>
        <div class="policy-list">
          <div
              v-for="(item, index) in currentTab.policies"
              :key="index"
              class="policy-item"
          >
            <div class="policy-content">
              <span class="dot">•</span>
              <span class="policy-text" :title="item.text">{{ truncateText(item.text) }}</span>
              <span class="policy-date">{{ item.date }}</span>
            </div>
            <div class="item-divider" v-if="index < currentTab.policies.length - 1"></div>
          </div>
        </div>
      </div>
    </div>

    <!-- 下部Tab内容 -->
    <div class="bottom-section">
      <div class="tab-container">
        <div
            v-for="(tab, index) in tabs"
            :key="index"
            class="tab-item"
        >
          <div class="section-header">
            <img :src="tab.icon" alt="图标" class="section-icon">
            <span class="more-text">——更多</span>
          </div>
          <div class="government-name">{{ tab.name }}</div>
          <div class="policy-list">
            <div
                v-for="(item, idx) in tab.policies"
                :key="idx"
                class="policy-item"
            >
              <div class="policy-content">
                <span class="dot">•</span>
                <span class="policy-text" :title="item.text">{{ truncateText(item.text) }}</span>
                <span class="policy-date">{{ item.date }}</span>
              </div>
              <div class="item-divider" v-if="idx < tab.policies.length - 1"></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
    <contact-footer></contact-footer>
  </div>
</template>

<script>
import ContactFooter from "@/view/homeComponents/banner.vue";

export default {
  components: {ContactFooter},
  data() {
    return {
      currentTab: {
        name: '人民政府',
        icon: require('@/assets/industrialPolicy/rmzf.svg'),
        policies: [
          { text: '关于促进数字经济高质量发展的若干政策措施', date: '2023-10-27' },
          { text: '关于开展2023年度科技创新项目申报工作的通知', date: '2023-10-26' },
          { text: '关于印发人工智能产业发展规划的通知', date: '2023-10-25' },
          { text: '关于发布绿色建筑评价标准的公告', date: '2023-10-24' }
        ]
      },
      tabs: [
        {
          name: '发展改革',
          icon: require('@/assets/industrialPolicy/fzgg.svg'),
          policies: [
            { text: '工业软件发展行动计划(2023-2025年)', date: '2023-10-23' },
            { text: '关于促进工业软件高质量发展的若干意见', date: '2023-10-22' },
            { text: '工业软件核心技术攻关项目申报指南', date: '2023-10-21' }
          ]
        },
        {
          name: '科技部门',
          icon: require('@/assets/industrialPolicy/kj.svg'),
          policies: [
            { text: '数字孪生技术应用白皮书(2023版)', date: '2023-10-20' },
            { text: '数字孪生城市建设指南', date: '2023-10-19' },
            { text: '制造业数字孪生应用案例集', date: '2023-10-18' }
          ]
        },
        {
          name: '工业经信',
          icon: require('@/assets/industrialPolicy/gyjx.svg'),
          policies: [
            { text: '工业安全防护技术规范', date: '2023-10-17' },
            { text: '工业互联网安全监测平台建设指南', date: '2023-10-16' },
            { text: '网络安全等级保护基本要求', date: '2023-10-15' }
          ]
        },
        {
          name: '规划统计',
          icon: require('@/assets/industrialPolicy/ghtj.svg'),
          policies: [
            { text: '工业软件发展行动计划(2023-2025年)', date: '2023-10-23' },
            { text: '关于促进工业软件高质量发展的若干意见', date: '2023-10-22' },
            { text: '工业软件核心技术攻关项目申报指南', date: '2023-10-21' }
          ]
        },
        {
          name: '大数据局',
          icon: require('@/assets/industrialPolicy/dsj.svg'),
          policies: [
            { text: '数字孪生技术应用白皮书(2023版)', date: '2023-10-20' },
            { text: '数字孪生城市建设指南', date: '2023-10-19' },
            { text: '制造业数字孪生应用案例集', date: '2023-10-18' }
          ]
        },
        {
          name: '文教广电',
          icon: require('@/assets/industrialPolicy/wjgd.svg'),
          policies: [
            { text: '工业安全防护技术规范', date: '2023-10-17' },
            { text: '工业互联网安全监测平台建设指南', date: '2023-10-16' },
            { text: '网络安全等级保护基本要求', date: '2023-10-15' }
          ]
        }
      ]
    };
  },
  methods: {
    truncateText(text) {
      const maxLength = 20;
      return text.length > maxLength ? text.substring(0, maxLength) + '...' : text;
    }
  }
};
</script>

<style scoped>
.bg-cont {
  background-color: #f5f5f5;
}
.department-container {
  max-width: 1200px;
  margin: 0 auto;

  padding: 20px;
  font-family: 'Microsoft YaHei', sans-serif;
}

/* 上部内容样式 */
.top-section {
  display: flex;
  margin-bottom: 30px;
}

.left-section {
  width: 30%;
  background-color: #FF9400;
  padding: 30px;
  height: 400px;
  box-sizing: border-box;
}

.department-title {
  font-size: 40px;
  color: white;
  font-weight: bold;
  margin-bottom: 30px;
  text-align: left;
}

.all-department-btn {
  width: 200px;
  padding: 12px 0;
  background-color: white;
  color: #FF9400;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 30px;
  cursor: pointer;
  text-align: center;
}

.divider-line {
  height: 1px;
  background-color: rgba(255, 255, 255, 0.5);
  margin-bottom: 30px;
}

.feature-list {
  color: white;
  font-size: 18px;
  line-height: 2;
  text-align: left;
}

.feature-item {
  margin-bottom: 15px;
}

.right-section {
  width: 70%;
  background-color: white;
  padding: 30px;
  height: 400px;
  box-sizing: border-box;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-icon {
  width: 36px;
  height: 36px;
}

.more-text {
  color: #999;
  font-size: 14px;
  cursor: pointer;
}

.government-name {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 20px;
  text-align: left;
}

.policy-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.policy-item {
  margin-bottom: 15px;
}

.policy-content {
  display: flex;
  align-items: center;
  padding: 5px 0;
}

.dot {
  font-size: 20px;
  margin-right: 10px;
}

.policy-text {
  flex: 1;
  font-size: 14px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 10px;
}

.policy-date {
  color: #999;
  font-size: 12px;
  text-align: right;
  min-width: 80px;
}

.item-divider {
  height: 1px;
  background-color: #f0f0f0;
}

/* 下部Tab内容样式 */
.bottom-section {
  background-color: white;
  padding: 20px;
}

.tab-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.tab-item {
  width: calc(33.33% - 14px);
  padding: 20px;
  box-sizing: border-box;
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .top-section {
    flex-direction: column;
  }

  .left-section, .right-section {
    width: 100%;
    height: auto;
  }

  .tab-item {
    width: 100%;
  }
}
</style>